/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2023-05-16
 * Time: 15:27
 */

public class Adapter extends BasicFun implements ScoreOperation{

    @Override
    public int binarySearch(int[] arr, int target) {
        int max = arr.length -1;
        int min = 0;
        int mid = min + (max - min) / 2;
        while(min < max){
            if(arr[mid] == target){
                return mid;
            }
            if(arr[mid] < target){
                min = mid + 1;
                mid = min + (max - min) / 2;
            }
            if(arr[mid] > target){
                max = mid - 1;
                mid = min + (max - min) / 2;
            }
        }
        return -1;
    }

    @Override
    public int[] qsort(int arr[],int start,int end) {
        int pivot = arr[start];
        int i = start;
        int j = end;
        while (i<j) {
            while ((i<j)&&(arr[j]>pivot)) {
                j--;
            }
            while ((i<j)&&(arr[i]<pivot)) {
                i++;
            }
            if ((arr[i]==arr[j])&&(i<j)) {
                i++;
            } else {
                int temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
            }
        }
        if (i-1>start) arr=qsort(arr,start,i-1);
        if (j+1<end) arr=qsort(arr,j+1,end);
        return (arr);
    }
}

